#ifndef __OS_FLAGGROUP_H
#define __OS_FLAGGROUP_H

#include "osEvent.h"

#define FLAGGROUP_CLEAR     (1 << 0)
#define FLAGGROUP_SET       (1 << 1)
#define FLAGGROUP_ANY       (1 << 2)
#define FLAGGROUP_ALL       (1 << 3)

#define FLAGGROUP_SET_ALL   (FLAGGROUP_SET | FLAGGROUP_ALL)     // 置位所有位
#define FLAGGROUP_SET_ANY   (FLAGGROUP_SET | FLAGGROUP_ANY)     // 置位任意位
#define FLAGGROUP_CLEAR_ALL (FLAGGROUP_CLEAR | FLAGGROUP_ALL)   // 清零所有位
#define FLAGGROUP_CLEAR_ANY (FLAGGROUP_CLEAR | FLAGGROUP_ANY)   // 清零任意位

#define FLAGGROUP_CONSUME   (1 << 7)                            // 是否消耗标志组
 




typedef struct _FLAGGROUP
{
    EVENT_T event;
    uint32_t flags;
} FLAGGROUP_T;

typedef struct _FLAGGROUP_INFO
{
    uint32_t taskCount;     // 等待事件任务数量
    uint32_t flags;         // 当前事件标志组的标志
} FLAGGROUP_INFO_T;


extern void     vFlagGroupInit(FLAGGROUP_T *fgroup, uint32_t flags);
extern uint32_t vFlagGroupWait(FLAGGROUP_T *fgroup, 
                                uint32_t waitType, 
                                uint32_t requestFlag, 
                                uint32_t *resultFlag, 
                                uint32_t timeout);
extern uint32_t vFlagGroupNoWait(FLAGGROUP_T *fgroup, 
                                uint32_t waitType, 
                                uint32_t requestFlag, 
                                uint32_t *resultFlag);
extern void     vFlagGroupNotify(FLAGGROUP_T *fgroup, uint8_t isSet, uint32_t flag);
extern uint32_t vFlagGroupDestroy(FLAGGROUP_T *fgroup);
extern void     vFlagGroupGetInfo(FLAGGROUP_T *fgroup, FLAGGROUP_INFO_T * info);

#endif // __OS_FLAGGROUP_H
